class BlogPostsController < ApplicationController 
  def index
     @blog_posts = BlogPost.all
   end
 

  def show
     @blog_post = BlogPost.find(params[:id])
   end
 

  def new
     @blog_post = BlogPost.new
     #@blog_post.user = User.find(params[:user_id])
     @blog_post.user_id = params[:user_id]
   end
 

  def create
     @blog_post = BlogPost.new(params[:blog_post])
     @blog_post.user = User.find(@blog_post.user_id)
     @blog_post.save
     redirect_to user_blog_post_path(@blog_post.user_id, @blog_post.id)
   end

  def destroy
     @blog_post = BlogPost.find(params[:id])
     @blog_post.destroy
     redirect_to user_blog_posts_path(session[:user_id])
   end
 end